﻿using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace DualPlaneFR4Paster.Migrations
{
    public partial class addMProduct : Migration
    {
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.CreateTable(
                name: "MPcs",
                columns: table => new
                {
                    Id = table.Column<int>(type: "INTEGER", nullable: false)
                        .Annotation("Sqlite:Autoincrement", true),
                    Index = table.Column<int>(type: "INTEGER", nullable: false),
                    X = table.Column<double>(type: "REAL", nullable: false),
                    Y = table.Column<double>(type: "REAL", nullable: false),
                    Z = table.Column<double>(type: "REAL", nullable: false),
                    Width = table.Column<double>(type: "REAL", nullable: false),
                    Height = table.Column<double>(type: "REAL", nullable: false),
                    X1 = table.Column<double>(type: "REAL", nullable: false),
                    Y1 = table.Column<double>(type: "REAL", nullable: false),
                    Z1 = table.Column<double>(type: "REAL", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_MPcs", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "MProducts",
                columns: table => new
                {
                    Id = table.Column<int>(type: "INTEGER", nullable: false)
                        .Annotation("Sqlite:Autoincrement", true),
                    PcsOrder = table.Column<int>(type: "INTEGER", nullable: false),
                    Order = table.Column<int>(type: "INTEGER", nullable: false),
                    Direction = table.Column<int>(type: "INTEGER", nullable: false),
                    StartX = table.Column<double>(type: "REAL", nullable: false),
                    StartY = table.Column<double>(type: "REAL", nullable: false),
                    EndX = table.Column<double>(type: "REAL", nullable: false),
                    EndY = table.Column<double>(type: "REAL", nullable: false),
                    Floor = table.Column<int>(type: "INTEGER", nullable: false),
                    PcsId = table.Column<int>(type: "INTEGER", nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_MProducts", x => x.Id);
                    table.ForeignKey(
                        name: "FK_MProducts_MPcs_PcsId",
                        column: x => x.PcsId,
                        principalTable: "MPcs",
                        principalColumn: "Id");
                });

            migrationBuilder.UpdateData(
                table: "MParams",
                keyColumn: "Id",
                keyValue: 17,
                column: "Name",
                value: "OrgX");

            migrationBuilder.UpdateData(
                table: "MParams",
                keyColumn: "Id",
                keyValue: 18,
                column: "Name",
                value: "OrgY");

            migrationBuilder.UpdateData(
                table: "MParams",
                keyColumn: "Id",
                keyValue: 19,
                column: "Name",
                value: "OrgX");

            migrationBuilder.UpdateData(
                table: "MParams",
                keyColumn: "Id",
                keyValue: 20,
                column: "Name",
                value: "OrgY");

            migrationBuilder.CreateIndex(
                name: "IX_MProducts_PcsId",
                table: "MProducts",
                column: "PcsId");
        }

        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropTable(
                name: "MProducts");

            migrationBuilder.DropTable(
                name: "MPcs");

            migrationBuilder.UpdateData(
                table: "MParams",
                keyColumn: "Id",
                keyValue: 17,
                column: "Name",
                value: "POrgX");

            migrationBuilder.UpdateData(
                table: "MParams",
                keyColumn: "Id",
                keyValue: 18,
                column: "Name",
                value: "POrgY");

            migrationBuilder.UpdateData(
                table: "MParams",
                keyColumn: "Id",
                keyValue: 19,
                column: "Name",
                value: "NOrgY");

            migrationBuilder.UpdateData(
                table: "MParams",
                keyColumn: "Id",
                keyValue: 20,
                column: "Name",
                value: "NOrgY");
        }
    }
}
